<template>
  <div style="padding-top: 20px">
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item label="按日期查找">
        <el-date-picker type="date" placeholder="日期" style="width: 100%;" />
      </el-form-item>
      <el-form-item label="按内容查找">
        <el-input placeholder="请输入内容" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
        <el-button type="success" @click="alreadyCheckStudentList">已审学生</el-button>
        <el-button type="danger" @click="listApply">未审学生</el-button>
      </el-form-item>
    </el-form>
    <div style="padding-top: 20px">
      <el-table
        :data="tableData"
        border
        style="width: 100%"
      >
        <el-table-column
          fixed
          label="序号"
          type="index"
          width="30"
        />
        <el-table-column
          prop="userName"
          label="申请人"
          width="70"
        />
        <el-table-column
          prop="sex"
          label="性别"
          width="40"
        />
        <el-table-column
          prop="tel"
          label="电话"
          width="120"
        />
        <el-table-column prop="photo" label="照片" width="150">
          <template slot-scope="scope">
            <a target="_blank" :href="scope.row.photo"><img :src="scope.row.photo" style="width: 150px;height: 110px"></a>
          </template>
        </el-table-column>
        <el-table-column
          prop="applyTime"
          label="申请时间"
          width="150"
        />
        <el-table-column
          prop="collegeName"
          label="部门"
          width="100"
        />
        <el-table-column
          prop="recruitName"
          label="标题"
          width="140"
        />
        <el-table-column
          prop="selfIntroduction"
          label="自我介绍"
          width="150"
        />
        <el-table-column
          prop="status"
          label="审核状态"
          width="120"
          filter-placement="bottom-end"
        >
          <template slot-scope="scope">
            <el-tag
              disable-transitions
            >{{ scope.row.status }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          fixed="right"
          label="操作"
          width="80"
        >
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="checkStudentApplyIsOK(scope.row.applyId,scope.row.email,'ok')">通过</el-button>
            <el-button type="text" size="small" @click="checkStudentApplyIsNO(scope.row.applyId,scope.row.email,'no')">不通过</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { getListApplyByRecruitId } from '../../api/Artisan'
import { checkStudentApply } from '../../api/Artisan'
import { alreadyCheckStudentList } from '../../api/Artisan'
export default {
  name: 'ViewRecruit',
  data() {
    return {
      tableData: [],
      studentList: []
    }
  },

  created() {
    this.listApply()
  },

  methods: {
    /**
             * 查看已经审核过的学生
             */
    alreadyCheckStudentList() {
      alreadyCheckStudentList().then(res => {
        this.tableData = res.data
      })
    },

    /**
             *申请的学生列表
             */
    listApply() {
      getListApplyByRecruitId().then(res => {
        if (res.data.errorCode === 30001) {
          this.$message('当前还没有申请的学生')
        }
        this.tableData = res.data
      }).catch(err => {
        this.$message.error('获取数据异常' + err)
      })
    },

    /**
             * 审核通过
             */
    checkStudentApplyIsOK(applyId, email, status) {
      checkStudentApply(applyId, email, status).then(res => {
        this.listApply()
        this.$message('审核完成')
      }).catch(err => {
        this.$message.error('审核出现异常' + err)
      })
    },

    /**
             * 审核不通过
             * @param applyId
             * @param email
             * @param status
             */
    checkStudentApplyIsNO(applyId, email, status) {
      checkStudentApply(applyId, email, status).then(res => {
        this.$message('审核完成')
      }).catch(error => {
        this.$message.error('审核出现异常' + error)
      })
    }
  }
}
</script>

<style scoped>

</style>
